package com.beetlestech.nfe.main.biz.com.impl;

import com.beetlestech.nfe.fw.core.biz.AbstractDBLogic;
import com.beetlestech.nfe.main.biz.com.HbHeadImage;
import com.beetlestech.nfe.main.biz.com.dto.VheadimageInfoDTO;
import com.beetlestech.nfe.main.biz.constant.CommonConstant;
import com.beetlestech.nfe.main.biz.constant.CtgCodeConstant;
import com.beetlestech.nfe.main.biz.constant.HbMessageCode;
import com.beetlestech.nfe.main.db.constant.SQLConstant;
import com.beetlestech.nfe.main.db.view.VheadimageDTO;
import com.beetlestech.nfe.main.db.view.support.VheadimageDTOSupport;

public class HbHeadImageImpl extends AbstractDBLogic implements HbHeadImage, CtgCodeConstant, HbMessageCode, CommonConstant, SQLConstant {

	@Override
	public VheadimageInfoDTO getHeadImage(Integer usr_id) {
		
		VheadimageDTO searchDTO = new VheadimageDTO();
		searchDTO.setusrid(usr_id);
		
		searchDTO = queryDAO.queryForObject(VheadimageDTOSupport.EQUAL_SEARCH, searchDTO);
		
		VheadimageInfoDTO headimageInfoDTO = new VheadimageInfoDTO();
		if (searchDTO == null) {
			//0件場合
			createApplicationException(M10090WS);
		} else {
			headimageInfoDTO = setheadimageInfo(searchDTO);
		}

		return headimageInfoDTO;
	}

	private VheadimageInfoDTO setheadimageInfo(VheadimageDTO targetDto){
		
		VheadimageInfoDTO convertDTO = new VheadimageInfoDTO();
		convertDTO.setusrid(targetDto.getusrid());
		convertDTO.setstudentid(targetDto.getusrid());
		convertDTO.setfileid(targetDto.getfileid());
		convertDTO.setpath(targetDto.getpath());
		
		return convertDTO;
	}

}
